<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class atheme extends CI_Model {

    var $view = 'theme/';
    var $data = array();
    var $theme = array();

    function __construct() {
        parent::__construct();
        $this->setData();
        $this->theme = array(
            'layout_main' => 'admin/layout_main',
            'content' => '',
        );
    }

    function setContent($theme_content) {
        $this->theme['content'] = "admin/" . $theme_content;
    }

    function setData($type = '', $name = '', $id = '', $class = '', $value = '', $attribute = '') {
        if ($id == '')
            $id = "myid_" . rand(0, 100);
        $this->data['type'] = $type;
        $this->data['name'] = $name;
        $this->data['id'] = $id;
        $this->data['class'] = $class;
        $this->data['value'] = $value;
        $this->data['attribute'] = $attribute;
    }

    function set($key, $val) {
        $this->data[$key] = $val;
    }

    function group_input($name, $label = '', $id = '', $class = '', $value = '', $type = 'text', $attribute = '') {
        $this->setData($type, $name, $id, $class, $value, $attribute);
        $this->data['label'] = $label;
        return $this->load->view($this->view . "group_input", $this->data, true);
    }

    function group_input2($name, $label = '', $id = '', $class = '', $value = '', $type = 'text', $attribute = '') {
        $this->setData($type, $name, $id, $class, $value, $attribute);
        $this->data['label'] = $label;
        return $this->load->view($this->view . "group_input2", $this->data, true);
    }

    function group_text2($label, $value) {
        $this->data['label'] = $label;
        $this->data['value'] = $value;
        return $this->load->view($this->view . "group_text2", $this->data, true);
    }

    function group_select2($name, $label = '', $id = '', $class = '', $value = array(), $default_value = '', $attribute = '') {
        $this->setData('', $name, $id, $class, $value, $attribute);
        $this->data['label'] = $label;
        $this->data['default_value'] = $default_value;
        return $this->load->view($this->view . "group_select2", $this->data, true);
    }

    function group_select($name, $label = '', $id = '', $class = '', $value = array(), $default_value = '', $attribute = '') {
        $this->setData('', $name, $id, $class, $value, $attribute);
        $this->data['label'] = $label;
        $this->data['default_value'] = $default_value;
        return $this->load->view($this->view . "group_select", $this->data, true);
    }

    function table_simple($header = array(), $data = array(), $config = array()) {
        $this->set('config', $config);
        foreach ($config as $k => $v)
            $this->set($k, $v);
        $this->set('header', $header);
        $this->set('datas', $data);
        return $this->load->view($this->view . "group_table", $this->data, true);
    }
	
	function form_search($data = array(), $config = array(), $default = array()) {
        $this->set('config', $config);
        foreach ($config as $k => $v)
            $this->set($k, $v);
        $this->set('datas', $data);
        $this->set('default', $default);
        return $this->load->view($this->view . "form_search", $this->data, true);
    }
	
	function group_single_upload($name, $label = '', $id = '', $class = '', $value = '', $type = 'text', $img_width ='', $img_height ='', $attribute = '') {
        $this->setData($type, $name, $id, $class, $value, $attribute);
        $this->data['label'] = $label;
        $this->data['img_width'] = $img_width;
        $this->data['img_height'] = $img_height;
        return $this->load->view($this->view . "group_single_upload", $this->data, true);
    }
}
